package org.elanfox.intellicommunity.biz.entity.equipment;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.elanfox.intellicommunity.biz.entity.embeddable.LocatorInfo;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;

/**
 * 定位器PO
 *
 * @author loutianxi
 * @date 2019-12-04
 */
@Entity
@Data
@Table(name = "t_locator")
public class LocatorPO extends EquipmentPO {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "locator_id")
    private Integer locatorId;
    /**
     * 定位器相关信息
     */
    private LocatorInfo locatorInfo;

    /**
     * 是否绑定基站的定位器
     */
    @Column(name = "binding_base_station")
    private boolean bindingBaseStation;

    /**
     * 前端是否显示
     */
    @Column(name = "is_show")
    private boolean show;

    /**
     * 用户持有卡
     */
    @OneToOne(mappedBy = "locator", fetch = FetchType.LAZY)
    @JsonIgnoreProperties("locator")
    @NotFound(action = NotFoundAction.IGNORE)
    private BaseStationPO baseStation;

    /**
     * 接受到定位消息是否立即报警
     */
    @Column(name = "is_alarmed_immediately")
    private boolean alarmedImmediately;

    /**
     * 触发报警的描述
     */
    @Column(name = "alarm_template")
    private String alarmTemplate;
    /**
     * 所属区域
     */
    @ManyToOne
    @JoinColumn(name = "rel_area_id")
    private LocatorAreaPO areaPO;
}
